package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CusvipData;
import com.ruoyi.system.service.ICusvipDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * VIP会员客户Controller
 * 
 * @author cyx
 * @date 2024-05-09
 */
@RestController
@RequestMapping("/system/data")
public class CusvipDataController extends BaseController
{
    @Autowired
    private ICusvipDataService cusvipDataService;

    /**
     * 查询VIP会员客户列表
     */
    @PreAuthorize("@ss.hasPermi('system:data:list')")
    @GetMapping("/list")
    public TableDataInfo list(CusvipData cusvipData)
    {
        startPage();
        List<CusvipData> list = cusvipDataService.selectCusvipDataList(cusvipData);
        return getDataTable(list);
    }

    /**
     * 导出VIP会员客户列表
     */
    @PreAuthorize("@ss.hasPermi('system:data:export')")
    @Log(title = "VIP会员客户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CusvipData cusvipData)
    {
        List<CusvipData> list = cusvipDataService.selectCusvipDataList(cusvipData);
        ExcelUtil<CusvipData> util = new ExcelUtil<CusvipData>(CusvipData.class);
        util.exportExcel(response, list, "VIP会员客户数据");
    }

    /**
     * 获取VIP会员客户详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:data:query')")
    @GetMapping(value = "/{dataId}")
    public AjaxResult getInfo(@PathVariable("dataId") Long dataId)
    {
        return success(cusvipDataService.selectCusvipDataByDataId(dataId));
    }

    /**
     * 新增VIP会员客户
     */
    @PreAuthorize("@ss.hasPermi('system:data:add')")
    @Log(title = "VIP会员客户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CusvipData cusvipData)
    {
        return toAjax(cusvipDataService.insertCusvipData(cusvipData));
    }

    /**
     * 修改VIP会员客户
     */
    @PreAuthorize("@ss.hasPermi('system:data:edit')")
    @Log(title = "VIP会员客户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CusvipData cusvipData)
    {
        return toAjax(cusvipDataService.updateCusvipData(cusvipData));
    }

    /**
     * 删除VIP会员客户
     */
    @PreAuthorize("@ss.hasPermi('system:data:remove')")
    @Log(title = "VIP会员客户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dataIds}")
    public AjaxResult remove(@PathVariable Long[] dataIds)
    {
        return toAjax(cusvipDataService.deleteCusvipDataByDataIds(dataIds));
    }
}
